package org.itboys.mobile.service.mongo.weixin.collection;

import org.itboys.commons.utils.tools.ListUtil;
import org.itboys.coo.entity.mongo.collection.CooCollection;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseMongoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者：zzq
 * 时间：2017/12/1
 * 描述：迈迪龙_微信_收藏
 */
@Service
public class CooWeixinCollectionService extends BaseMongoService<CooCollection>{
    @Resource(name = "mdlDs")
    private MongoDataSource mdlDataSource;
    @Override
    protected MongoDataSource getMongoDataSource() {
        return mdlDataSource;
    }

    @Override
    protected Class<CooCollection> getEntityClass() {
        return CooCollection.class;
    }

    /**
     * 判断用户是否收藏。 1商品，2待定
     * @param memberId
     * @param type
     * @return
     */
    public Integer checkIsCollection(Long memberId,Integer type,Long otherId){

        Map<String,Object> param=new HashMap<String,Object>();
        param.put("memberId",memberId);
        param.put("type",type);
        param.put("otherId",otherId);
        List<CooCollection> collections=super.list(param);
        if(ListUtil.isNotNull(collections)){
            return 1;
        }
        return 0;
    }
}
